<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.company.ems.model.User" %>
<%
    User user = (User) session.getAttribute("user");
%>
<html>
<head>
    <title>添加员工</title>
    <link rel="stylesheet" type="text/css" href="../css/style.css">
</head>
<body>
<div class="header">
    <h1>添加员工</h1>
    <div class="user-info">
        欢迎, <%= user != null ? user.getUsername() : "" %>
        | <a href="../logout">退出登录</a>
    </div>
</div>

<div class="menu">
    <a href="../dashboard">返回主页</a>
    <a href="employee">返回列表</a>
</div>

<div class="content">
    <h2>添加新员工</h2>

    <form action="employee" method="post">
        <input type="hidden" name="action" value="insert">

        <div class="form-group">
            <label for="name">姓名:</label>
            <input type="text" id="name" name="name" required
                   placeholder="请输入员工姓名">
        </div>

        <div class="form-group">
            <label for="department">部门:</label>
            <input type="text" id="department" name="department" required
                   placeholder="请输入部门名称">
        </div>

        <div class="form-group">
            <label for="position">职位:</label>
            <input type="text" id="position" name="position" required
                   placeholder="请输入职位">
        </div>

        <div class="form-group">
            <label for="salary">薪资:</label>
            <input type="number" id="salary" name="salary" step="0.01"
                   min="0" required placeholder="请输入薪资">
        </div>

        <div class="form-group">
            <label for="email">邮箱:</label>
            <input type="email" id="email" name="email"
                   placeholder="请输入邮箱地址">
        </div>

        <div class="form-group">
            <label for="phone">电话:</label>
            <input type="text" id="phone" name="phone"
                   placeholder="请输入电话号码">
        </div>

        <div class="form-group">
            <label for="hire_date">入职日期:</label>
            <input type="date" id="hire_date" name="hire_date" required>
        </div>

        <div style="margin-top: 1.5rem;">
            <button type="submit">添加员工</button>
            <a href="employee" class="btn-cancel">取消</a>
        </div>
    </form>
</div>

<script>
    // 设置默认日期为今天
    document.getElementById('hire_date').valueAsDate = new Date();
</script>
</body>
</html>